package com.ss.pj.sc04.service.fallback;

import com.ss.pj.sc01.pojo.User;
import com.ss.pj.sc01.vo.JsonResult;
import com.ss.pj.sc04.feign.client.UserFeignService;
import org.springframework.stereotype.Component;

/**
 * 获取用户信息的降级方法，模拟使用缓存数据
 * @author 叁昇
 * @create 2020-11-24-22:34
 */
@Component
public class UserFeignServiceFB implements UserFeignService {
    @Override
    public JsonResult<User> getUser(Integer userId) {
        if(Math.random()<0.4) {
            return JsonResult.ok(new User(userId, "缓存name"+userId, "缓存pwd"+userId));
        }
        return JsonResult.err("无法获取用户信息");
    }

    @Override
    public JsonResult addScore(Integer userId, Integer score) {
        return JsonResult.err("无法增加用户积分");
    }
}
